<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>创建拼团活动</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        }
    </style>
</head>
<body class="bg-gray-100">
    <div class="mx-auto max-w-[393px] h-[852px] bg-white relative overflow-hidden rounded-[40px] shadow-2xl">
        <!-- Status Bar -->
        <div class="bg-white px-6 pt-3 pb-2">
            <div class="flex justify-between items-center text-xs">
                <span class="font-semibold">9:41</span>
                <div class="flex space-x-1">
                    <i class="fas fa-signal"></i>
                    <i class="fas fa-wifi"></i>
                    <i class="fas fa-battery-full"></i>
                </div>
            </div>
        </div>

        <!-- Header -->
        <div class="bg-gradient-to-r from-green-500 to-emerald-500 px-4 py-3">
            <div class="flex items-center justify-between text-white">
                <a href="b2b-marketing.html" class="text-white">
                    <i class="fas fa-arrow-left text-lg"></i>
                </a>
                <h1 class="text-lg font-semibold">创建拼团活动</h1>
                <button onclick="saveDraft()" class="text-white hover:opacity-80">
                    <i class="fas fa-save text-lg"></i>
                </button>
            </div>
        </div>

        <!-- Content -->
        <div class="h-[calc(852px-160px)] overflow-y-auto pb-4">
            <form id="groupBuyingForm">
                <!-- Activity Basic Info -->
                <div class="bg-white border-b border-gray-200">
                    <div class="px-4 py-4">
                        <h3 class="font-medium mb-4 flex items-center">
                            <i class="fas fa-users text-green-500 mr-2"></i>
                            活动基本信息
                        </h3>
                        
                        <div class="space-y-4">
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-2">活动名称</label>
                                <input type="text" id="activityName" placeholder="请输入拼团活动名称" 
                                       class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent">
                            </div>
                            
                            <div class="grid grid-cols-2 gap-3">
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-2">开始时间</label>
                                    <input type="datetime-local" id="startTime" 
                                           class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-green-500 focus:border-transparent">
                                </div>
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-2">结束时间</label>
                                    <input type="datetime-local" id="endTime" 
                                           class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-green-500 focus:border-transparent">
                                </div>
                            </div>

                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-2">活动说明</label>
                                <textarea id="description" rows="3" placeholder="请输入拼团活动说明，介绍拼团规则和优势"
                                          class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent resize-none"></textarea>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Group Rules -->
                <div class="bg-white border-b border-gray-200">
                    <div class="px-4 py-4">
                        <h3 class="font-medium mb-4 flex items-center">
                            <i class="fas fa-handshake text-blue-500 mr-2"></i>
                            拼团规则
                        </h3>
                        
                        <div class="space-y-4">
                            <div class="grid grid-cols-2 gap-3">
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-2">成团人数</label>
                                    <div class="flex items-center">
                                        <input type="number" id="groupSize" min="2" max="20" placeholder="3" 
                                               class="flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent">
                                        <span class="ml-2 text-sm text-gray-600">人</span>
                                    </div>
                                </div>
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-2">拼团时限</label>
                                    <div class="flex items-center">
                                        <input type="number" id="groupTimeLimit" min="1" max="72" placeholder="24" 
                                               class="flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent">
                                        <span class="ml-2 text-sm text-gray-600">小时</span>
                                    </div>
                                </div>
                            </div>

                            <div class="grid grid-cols-2 gap-3">
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-2">每人限购</label>
                                    <div class="flex items-center">
                                        <input type="number" id="purchaseLimit" min="1" max="10" placeholder="2" 
                                               class="flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent">
                                        <span class="ml-2 text-sm text-gray-600">件</span>
                                    </div>
                                </div>
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-2">开团奖励</label>
                                    <div class="flex items-center">
                                        <span class="text-sm text-gray-600 mr-1">¥</span>
                                        <input type="number" id="leaderReward" min="0" step="0.01" placeholder="5" 
                                               class="flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent">
                                    </div>
                                </div>
                            </div>

                            <div>
                                <label class="flex items-center text-sm">
                                    <input type="checkbox" id="autoRefund" checked class="mr-2 text-green-500 focus:ring-green-500">
                                    <span class="text-gray-700">拼团失败自动退款</span>
                                </label>
                                <p class="text-xs text-gray-500 mt-1 ml-6">拼团人数不足时，自动原路退还已支付金额</p>
                            </div>

                            <div>
                                <label class="flex items-center text-sm">
                                    <input type="checkbox" id="allowJoinMultiple" class="mr-2 text-green-500 focus:ring-green-500">
                                    <span class="text-gray-700">允许参与多个拼团</span>
                                </label>
                                <p class="text-xs text-gray-500 mt-1 ml-6">同一用户可以参与多个不同的拼团</p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Product and Price Settings -->
                <div class="bg-white border-b border-gray-200">
                    <div class="px-4 py-4">
                        <div class="flex items-center justify-between mb-4">
                            <h3 class="font-medium flex items-center">
                                <i class="fas fa-tag text-purple-500 mr-2"></i>
                                商品与价格
                            </h3>
                            <button type="button" onclick="selectProduct()" 
                                    class="bg-green-100 text-green-600 text-sm px-3 py-1 rounded-lg hover:bg-green-200 transition-colors">
                                选择商品
                            </button>
                        </div>
                        
                        <div id="selectedProduct" class="space-y-3">
                            <div class="text-center py-8 text-gray-500">
                                <i class="fas fa-shopping-bag text-4xl mb-2"></i>
                                <p>还未选择商品</p>
                                <p class="text-xs">点击"选择商品"选择拼团商品</p>
                            </div>
                        </div>

                        <div id="priceSettings" class="mt-4" style="display: none;">
                            <div class="bg-gray-50 rounded-lg p-3">
                                <div class="grid grid-cols-2 gap-3">
                                    <div>
                                        <label class="block text-sm font-medium text-gray-700 mb-2">原价</label>
                                        <div class="flex items-center">
                                            <span class="text-sm text-gray-600 mr-1">¥</span>
                                            <input type="number" id="originalPrice" readonly 
                                                   class="flex-1 px-3 py-2 border border-gray-300 rounded-lg bg-gray-100 text-gray-600">
                                        </div>
                                    </div>
                                    <div>
                                        <label class="block text-sm font-medium text-gray-700 mb-2">拼团价</label>
                                        <div class="flex items-center">
                                            <span class="text-sm text-gray-600 mr-1">¥</span>
                                            <input type="number" id="groupPrice" min="0" step="0.01" placeholder="优惠价格" 
                                                   class="flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent">
                                        </div>
                                    </div>
                                </div>
                                <div class="mt-3 text-center">
                                    <span class="text-sm text-gray-600">节省: </span>
                                    <span id="savings" class="text-sm font-medium text-red-600">¥0</span>
                                    <span class="ml-3 text-sm text-gray-600">折扣: </span>
                                    <span id="discount" class="text-sm font-medium text-green-600">10折</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Social Sharing Settings -->
                <div class="bg-white border-b border-gray-200">
                    <div class="px-4 py-4">
                        <h3 class="font-medium mb-4 flex items-center">
                            <i class="fas fa-share-alt text-orange-500 mr-2"></i>
                            分享设置
                        </h3>
                        
                        <div class="space-y-4">
                            <div>
                                <label class="flex items-center text-sm">
                                    <input type="checkbox" id="enableShare" checked class="mr-2 text-green-500 focus:ring-green-500">
                                    <span class="text-gray-700">开启分享功能</span>
                                </label>
                                <p class="text-xs text-gray-500 mt-1 ml-6">用户可分享拼团活动邀请好友参与</p>
                            </div>

                            <div>
                                <label class="flex items-center text-sm">
                                    <input type="checkbox" id="shareReward" class="mr-2 text-green-500 focus:ring-green-500">
                                    <span class="text-gray-700">分享奖励</span>
                                </label>
                                <div id="shareRewardSettings" class="mt-2 ml-6" style="display: none;">
                                    <div class="flex items-center">
                                        <span class="text-sm text-gray-600 mr-2">每成功邀请1人奖励</span>
                                        <span class="text-sm text-gray-600 mr-1">¥</span>
                                        <input type="number" id="shareRewardAmount" min="0" step="0.01" placeholder="2" 
                                               class="w-16 px-2 py-1 border border-gray-300 rounded text-sm focus:ring-2 focus:ring-green-500 focus:border-transparent">
                                    </div>
                                </div>
                            </div>

                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-2">分享文案</label>
                                <textarea id="shareText" rows="2" placeholder="快来和我一起拼团，超值优惠不容错过！"
                                          class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent resize-none text-sm"></textarea>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Marketing Promotion -->
                <div class="bg-white border-b border-gray-200">
                    <div class="px-4 py-4">
                        <h3 class="font-medium mb-4 flex items-center">
                            <i class="fas fa-bullhorn text-pink-500 mr-2"></i>
                            营销推广
                        </h3>
                        
                        <div class="space-y-4">
                            <div>
                                <label class="flex items-center text-sm">
                                    <input type="checkbox" id="homePagePromo" class="mr-2 text-green-500 focus:ring-green-500">
                                    <span class="text-gray-700">首页推广位展示</span>
                                </label>
                                <p class="text-xs text-gray-500 mt-1 ml-6">活动将在首页拼团专区显示</p>
                            </div>

                            <div>
                                <label class="flex items-center text-sm">
                                    <input type="checkbox" id="pushNotification" class="mr-2 text-green-500 focus:ring-green-500">
                                    <span class="text-gray-700">开团提醒推送</span>
                                </label>
                                <p class="text-xs text-gray-500 mt-1 ml-6">有新团开启时推送给相关用户</p>
                            </div>

                            <div>
                                <label class="flex items-center text-sm">
                                    <input type="checkbox" id="urgencyReminder" class="mr-2 text-green-500 focus:ring-green-500">
                                    <span class="text-gray-700">成团倒计时提醒</span>
                                </label>
                                <p class="text-xs text-gray-500 mt-1 ml-6">拼团即将结束前1小时提醒参团用户</p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Activity Preview -->
                <div class="bg-white">
                    <div class="px-4 py-4">
                        <h3 class="font-medium mb-4 flex items-center">
                            <i class="fas fa-eye text-indigo-500 mr-2"></i>
                            活动预览
                        </h3>
                        
                        <div class="bg-gradient-to-r from-green-50 to-emerald-50 rounded-lg p-4 border border-green-200">
                            <div class="flex items-center justify-between mb-3">
                                <div class="flex items-center">
                                    <span class="bg-green-500 text-white text-xs px-2 py-1 rounded-full font-medium">
                                        <i class="fas fa-users mr-1"></i>拼团
                                    </span>
                                    <span class="ml-2 text-xs text-gray-600">还差<span id="previewRemaining">2</span>人成团</span>
                                </div>
                                <span class="text-xs text-orange-600">剩余23:45:30</span>
                            </div>
                            <h4 id="previewName" class="text-sm font-medium mb-2 text-gray-800">活动名称将在这里显示</h4>
                            <div class="flex items-center justify-between">
                                <div class="flex items-baseline">
                                    <span class="text-xs text-gray-500">拼团价</span>
                                    <span id="previewGroupPrice" class="text-lg font-bold text-red-600 ml-1">¥0</span>
                                    <span id="previewOriginalPrice" class="text-xs text-gray-400 line-through ml-2">¥0</span>
                                </div>
                                <div class="text-right text-xs text-gray-600">
                                    <span id="previewGroupSize">3</span>人团
                                </div>
                            </div>
                            <div class="mt-3 flex items-center">
                                <div class="flex -space-x-1">
                                    <div class="w-6 h-6 bg-blue-500 rounded-full border-2 border-white flex items-center justify-center">
                                        <i class="fas fa-user text-white text-xs"></i>
                                    </div>
                                    <div class="w-6 h-6 bg-gray-300 rounded-full border-2 border-white flex items-center justify-center">
                                        <i class="fas fa-plus text-gray-600 text-xs"></i>
                                    </div>
                                    <div class="w-6 h-6 bg-gray-300 rounded-full border-2 border-white flex items-center justify-center">
                                        <i class="fas fa-plus text-gray-600 text-xs"></i>
                                    </div>
                                </div>
                                <span class="ml-3 text-xs text-gray-600">已有1人参团</span>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>

        <!-- Bottom Actions -->
        <div class="absolute bottom-0 left-0 right-0 bg-white border-t border-gray-200 p-4">
            <div class="flex gap-3">
                <button onclick="saveDraft()" class="flex-1 bg-gray-100 text-gray-700 py-3 rounded-lg font-medium hover:bg-gray-200 transition-colors">
                    保存草稿
                </button>
                <button onclick="createGroupBuying()" class="flex-1 bg-gradient-to-r from-green-500 to-emerald-500 text-white py-3 rounded-lg font-medium hover:opacity-90 transition-opacity shadow-lg">
                    创建拼团
                </button>
            </div>
        </div>
    </div>

    <!-- Product Selection Modal -->
    <div id="productModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
        <div class="bg-white rounded-t-3xl w-full max-w-[393px] mx-4 max-h-[70vh] overflow-hidden">
            <div class="flex items-center justify-between p-4 border-b border-gray-200">
                <h3 class="text-lg font-semibold">选择商品</h3>
                <button onclick="closeProductModal()" class="text-gray-500 hover:text-gray-700">
                    <i class="fas fa-times text-xl"></i>
                </button>
            </div>
            
            <div class="p-4 overflow-y-auto max-h-[calc(70vh-120px)]">
                <div class="space-y-3" id="productList">
                    <div class="flex items-center p-3 border border-gray-200 rounded-lg cursor-pointer hover:bg-gray-50" onclick="selectProductItem(this, 'BT001', '无线蓝牙耳机 Pro Max', '299', 'https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=60&h=60&fit=crop')">
                        <input type="radio" name="selectedProduct" class="mr-3">
                        <img src="https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=60&h=60&fit=crop" class="w-12 h-12 rounded-lg mr-3">
                        <div class="flex-1">
                            <h4 class="text-sm font-medium">无线蓝牙耳机 Pro Max</h4>
                            <div class="flex items-center mt-1">
                                <span class="text-sm text-red-600 font-bold">¥299</span>
                                <span class="text-xs text-gray-500 line-through ml-2">¥399</span>
                                <span class="text-xs text-green-600 ml-2">库存186</span>
                            </div>
                        </div>
                    </div>

                    <div class="flex items-center p-3 border border-gray-200 rounded-lg cursor-pointer hover:bg-gray-50" onclick="selectProductItem(this, 'PB001', '便携充电宝 20000mAh', '89', 'https://images.unsplash.com/photo-1484704849700-f032a568e944?w=60&h=60&fit=crop')">
                        <input type="radio" name="selectedProduct" class="mr-3">
                        <img src="https://images.unsplash.com/photo-1484704849700-f032a568e944?w=60&h=60&fit=crop" class="w-12 h-12 rounded-lg mr-3">
                        <div class="flex-1">
                            <h4 class="text-sm font-medium">便携充电宝 20000mAh</h4>
                            <div class="flex items-center mt-1">
                                <span class="text-sm text-red-600 font-bold">¥89</span>
                                <span class="text-xs text-gray-500 line-through ml-2">¥129</span>
                                <span class="text-xs text-green-600 ml-2">库存325</span>
                            </div>
                        </div>
                    </div>

                    <div class="flex items-center p-3 border border-gray-200 rounded-lg cursor-pointer hover:bg-gray-50" onclick="selectProductItem(this, 'KB001', '无线键盘鼠标套装', '159', 'https://images.unsplash.com/photo-1585298723682-7115561c51b7?w=60&h=60&fit=crop')">
                        <input type="radio" name="selectedProduct" class="mr-3">
                        <img src="https://images.unsplash.com/photo-1585298723682-7115561c51b7?w=60&h=60&fit=crop" class="w-12 h-12 rounded-lg mr-3">
                        <div class="flex-1">
                            <h4 class="text-sm font-medium">无线键盘鼠标套装</h4>
                            <div class="flex items-center mt-1">
                                <span class="text-sm text-red-600 font-bold">¥159</span>
                                <span class="text-xs text-gray-500 line-through ml-2">¥229</span>
                                <span class="text-xs text-green-600 ml-2">库存96</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="flex gap-3 p-4 border-t border-gray-200">
                <button onclick="closeProductModal()" class="flex-1 bg-gray-100 text-gray-700 py-2 rounded-lg font-medium">
                    取消
                </button>
                <button onclick="confirmProductSelection()" class="flex-1 bg-green-500 text-white py-2 rounded-lg font-medium">
                    确认选择
                </button>
            </div>
        </div>
    </div>

    <script>
        let selectedProductData = null;

        // Form preview updates
        document.getElementById('activityName').addEventListener('input', function() {
            document.getElementById('previewName').textContent = this.value || '活动名称将在这里显示';
        });

        document.getElementById('groupSize').addEventListener('input', function() {
            const size = this.value || '3';
            document.getElementById('previewGroupSize').textContent = size;
            document.getElementById('previewRemaining').textContent = Math.max(0, parseInt(size) - 1);
        });

        document.getElementById('groupPrice').addEventListener('input', updatePricePreview);
        document.getElementById('originalPrice').addEventListener('input', updatePricePreview);

        function updatePricePreview() {
            const original = parseFloat(document.getElementById('originalPrice').value) || 0;
            const groupPrice = parseFloat(document.getElementById('groupPrice').value) || 0;
            
            document.getElementById('previewGroupPrice').textContent = '¥' + groupPrice;
            document.getElementById('previewOriginalPrice').textContent = '¥' + original;
            
            if (original > 0 && groupPrice > 0) {
                const savings = original - groupPrice;
                const discount = ((groupPrice / original) * 10).toFixed(1);
                
                document.getElementById('savings').textContent = '¥' + savings.toFixed(2);
                document.getElementById('discount').textContent = discount + '折';
            }
        }

        // Share reward settings toggle
        document.getElementById('shareReward').addEventListener('change', function() {
            const settings = document.getElementById('shareRewardSettings');
            settings.style.display = this.checked ? 'block' : 'none';
        });

        // Product selection functions
        function selectProduct() {
            document.getElementById('productModal').classList.remove('hidden');
        }

        function closeProductModal() {
            document.getElementById('productModal').classList.add('hidden');
        }

        function selectProductItem(element, id, name, price, image) {
            // Clear other selections
            document.querySelectorAll('#productList input[type="radio"]').forEach(radio => {
                radio.checked = false;
                radio.closest('.flex').classList.remove('border-green-500', 'bg-green-50');
            });
            
            // Select current item
            const radio = element.querySelector('input[type="radio"]');
            radio.checked = true;
            element.classList.add('border-green-500', 'bg-green-50');
            
            selectedProductData = { id, name, price, image };
        }

        function confirmProductSelection() {
            if (!selectedProductData) {
                showToast('请选择一个商品');
                return;
            }
            
            updateSelectedProductDisplay();
            closeProductModal();
        }

        function updateSelectedProductDisplay() {
            const container = document.getElementById('selectedProduct');
            const priceSettings = document.getElementById('priceSettings');
            
            container.innerHTML = `
                <div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg">
                    <div class="flex items-center">
                        <img src="${selectedProductData.image}" class="w-12 h-12 rounded-lg mr-3">
                        <div>
                            <h4 class="text-sm font-medium">${selectedProductData.name}</h4>
                            <span class="text-sm text-gray-600">商品ID: ${selectedProductData.id}</span>
                        </div>
                    </div>
                    <button onclick="removeSelectedProduct()" class="text-red-500 hover:text-red-700">
                        <i class="fas fa-trash text-sm"></i>
                    </button>
                </div>
            `;
            
            // Update price settings
            document.getElementById('originalPrice').value = selectedProductData.price;
            document.getElementById('groupPrice').value = Math.max(1, parseFloat(selectedProductData.price) * 0.8).toFixed(2);
            priceSettings.style.display = 'block';
            
            updatePricePreview();
        }

        function removeSelectedProduct() {
            selectedProductData = null;
            document.getElementById('selectedProduct').innerHTML = `
                <div class="text-center py-8 text-gray-500">
                    <i class="fas fa-shopping-bag text-4xl mb-2"></i>
                    <p>还未选择商品</p>
                    <p class="text-xs">点击"选择商品"选择拼团商品</p>
                </div>
            `;
            document.getElementById('priceSettings').style.display = 'none';
        }

        // Form actions
        function saveDraft() {
            const formData = gatherFormData();
            showToast('拼团活动草稿已保存');
        }

        function createGroupBuying() {
            const formData = gatherFormData();
            
            // Basic validation
            if (!formData.activityName) {
                showToast('请输入活动名称');
                return;
            }
            
            if (!formData.startTime || !formData.endTime) {
                showToast('请设置活动时间');
                return;
            }
            
            if (!selectedProductData) {
                showToast('请选择拼团商品');
                return;
            }

            if (!formData.groupPrice || parseFloat(formData.groupPrice) <= 0) {
                showToast('请设置拼团价格');
                return;
            }

            // Success simulation
            showToast('拼团活动创建成功！');
            
            setTimeout(() => {
                window.location.href = 'b2b-marketing.html';
            }, 1500);
        }

        function gatherFormData() {
            return {
                activityName: document.getElementById('activityName').value,
                startTime: document.getElementById('startTime').value,
                endTime: document.getElementById('endTime').value,
                description: document.getElementById('description').value,
                groupSize: document.getElementById('groupSize').value,
                groupTimeLimit: document.getElementById('groupTimeLimit').value,
                purchaseLimit: document.getElementById('purchaseLimit').value,
                leaderReward: document.getElementById('leaderReward').value,
                autoRefund: document.getElementById('autoRefund').checked,
                allowJoinMultiple: document.getElementById('allowJoinMultiple').checked,
                originalPrice: document.getElementById('originalPrice').value,
                groupPrice: document.getElementById('groupPrice').value,
                enableShare: document.getElementById('enableShare').checked,
                shareReward: document.getElementById('shareReward').checked,
                shareRewardAmount: document.getElementById('shareRewardAmount').value,
                shareText: document.getElementById('shareText').value,
                homePagePromo: document.getElementById('homePagePromo').checked,
                pushNotification: document.getElementById('pushNotification').checked,
                urgencyReminder: document.getElementById('urgencyReminder').checked,
                selectedProduct: selectedProductData
            };
        }

        // Toast notification
        function showToast(message) {
            const toast = document.createElement('div');
            toast.className = 'fixed top-20 left-1/2 transform -translate-x-1/2 bg-gray-800 text-white px-4 py-2 rounded-lg text-sm z-50';
            toast.textContent = message;
            document.body.appendChild(toast);
            
            setTimeout(() => {
                toast.remove();
            }, 2000);
        }

        // Initialize page
        document.addEventListener('DOMContentLoaded', function() {
            // Set default times
            const now = new Date();
            const tomorrow = new Date(now.getTime() + 24 * 60 * 60 * 1000);
            const weekLater = new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000);
            
            document.getElementById('startTime').value = tomorrow.toISOString().slice(0, 16);
            document.getElementById('endTime').value = weekLater.toISOString().slice(0, 16);
        });
    </script>
</body>
</html>